﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework2._3
{
    class Program
    {
        static void Main(string[] args)
        {
            int NumberOfRows = -1;//初始化行数为-1
            while (NumberOfRows < 0)
            {
                Console.Write("请输入目标菱形的上半部分行数（大于零的整数）：");
                int.TryParse(Console.ReadLine(), out NumberOfRows);//检查能否转换成功并放入result中
            }
            if (NumberOfRows > 0)
            {
                for (int i = 1; i <= NumberOfRows; i++)
                {
                    for (int j = 1; j <= NumberOfRows-i; j++)
                    {
                        Console.Write(" ");
                    }
                    for (int k = 1; k <= 2*i-1; k++)
                    {
                        Console.Write("*");
                    } 
                Console.WriteLine(""); 
                }
                for (int i = NumberOfRows-1; i >=1; i--)
                {
                    for (int j = 1; j <= NumberOfRows - i; j++)
                    {
                        Console.Write(" ");
                    }
                    for (int k = 1; k <= 2 * i - 1; k++)
                    {
                        Console.Write("*");
                    }
                    Console.WriteLine("");
                }
            }
            

            Console.WriteLine("按任意键结束...");
            Console.ReadKey();
        }
    }
}
